import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';

@Index('user_id', ['email'], {})
@Entity('verification_codes', { schema: 'vote' })
export class VerificationCodes {
  @PrimaryGeneratedColumn({ type: 'int', name: 'id' })
  id: number;

  @Column('varchar', { name: 'email', comment: '邮箱地址', length: 50 })
  email: string;

  @Column('varchar', { name: 'code', comment: '验证码', length: 6 })
  code: string;

  @Column('int', {
    name: 'expires_at',
    comment: '验证码过期时间',
    default: () => "'0'",
  })
  expiresAt: number;

  @Column('tinyint', {
    name: 'status',
    comment: '状态，0未使用，1已使用，2已过期',
    default: () => "'0'",
  })
  status: number;
}
